[17.0][ADD] survey_question_type_model_selection: new module#209
[17.0][ADD] survey_question_type_model_selection: new module#209eduezerouali-tecnativa wants to merge 1 commit intoOCA:17.0from
Conversation
6a9e1c1 to
433d4bc
Compare
a197d13 to
366a795
Compare
5b5422e to
82e6168
Compare
613de04 to
a60e05b
Compare
| "survey_id": cls.survey.id, | ||
| "title": "State", | ||
| "question_type": "model", | ||
| "question_model_id": 81, |
There was a problem hiding this comment.
What does ID 81 correspond to? I think you should use the _get function instead of hardcoding the ID here,
like the default value self.env["ir.model"]._get_id("model.name").
| <div | ||
| class="col-sm-12 o_survey_choice_btn py-1 px-3 w-100 h-100 rounded mb-3" | ||
| > | ||
| <span t-out="answer_lines[0].value_model.display_name or None" /> |
There was a problem hiding this comment.
This already fix, now it manages if it has no answer.
| setTimeout(() => this._initAllInputs(), 100); | ||
| setTimeout(() => this._initAllInputs(), 500); | ||
| setTimeout(() => this._initAllInputs(), 1000); |
There was a problem hiding this comment.
I don't understand why we do the same thing with different intervals. Could you add a better comment or docstring?
There was a problem hiding this comment.
Not really need it, it is done in this._setupObserver(); ,we need init the selection. becuse when DOM is display first time it is not load. I don't know if there is a more practical way of implementing it.
| errorMsg.style.fontSize = "0.875rem"; | ||
| errorMsg.style.marginTop = "0.25rem"; | ||
| errorMsg.style.display = "none"; | ||
| errorMsg.textContent = "Please select a valid option from the list"; |
There was a problem hiding this comment.
I think this text can be translated.
There was a problem hiding this comment.
Now it can be translated
bc6ae2e to
6b79df2
Compare
|
@carlos-lopez-tecnativa thanks to take the time for review this PR. I did attend your comments. It is ready for review again. Thank you. |
| if (!applySurveyPatch()) { | ||
| let attempts = 0; | ||
| const maxAttempts = 50; | ||
| const interval = setInterval(() => { | ||
| attempts++; | ||
| if (applySurveyPatch()) { | ||
| clearInterval(interval); | ||
| } else if (attempts >= maxAttempts) { | ||
| clearInterval(interval); | ||
| } | ||
| }, 100); | ||
| } |
There was a problem hiding this comment.
Why? Could you add a docstring to explain the reason for this code? It is not clear to me.
I imagine the DOM is not ready yet, but what is the actual reason?
| import publicWidget from "@web/legacy/js/public/public_widget"; | ||
|
|
||
| publicWidget.registry.SurveyModelInput = publicWidget.Widget.extend({ | ||
| selector: ".js_surveyform, .o_survey_form, body", |
There was a problem hiding this comment.
I’m not sure if this code is loaded correctly. I attached a video where, if I start the survey from the test (or more specifically, if it displays the main page before starting the survey), it works fine. However, when I start the survey from a link from the Share wizard, it does not display the main page. The first question is loaded, but the input does not display the options. I suspect it is not loading correctly. Please take a look.
survey_question_type_model_selection.mp4
|
I see the code adds a feature to allow the user to select options, similar to a many2one field, which is nice, but what is the reason for implementing this here? Could an external library be used instead, such as |
|
For such simple feature, it's better to not add such maintenance burden. |
6b79df2 to
6f30609
Compare
|
Add choices to it. Main changes apply:
Changes do not affect following PR #210 #211 please @pilarvargas-tecnativa @carlos-lopez-tecnativa could you review. |





This module extends the Survey question types by introducing a new question type that allows selecting records from any model, with configurable domain filters. This makes it possible to display dynamic, filtered model-based selections directly within surveys.
@Tecnativa TT59700
ping @pilarvargas-tecnativa @carlos-lopez-tecnativa @pedrobaeza